<html>

<head>
	<title>打开小程序</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
	<!-- weui 样式 -->
	<link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/2.4.1/weui.min.css">
	</link>
	<style>
		.full {
			position: absolute;
			top: 0;
			bottom: 0;
			left: 0;
			right: 0;
		}

		#public-web-container {
			display: flex;
			flex-direction: column;
			align-items: center;
		}

		#public-web-container p {
			position: absolute;
			top: 40%;
		}

		#public-web-container a {
			position: absolute;
			bottom: 40%;
		}
	</style>
	<script src="/assets/libs/jquery/dist/jquery.js"></script>
	<script>
		function set(key, value) {
			var curTime = new Date().getTime();
			localStorage.setItem(key, JSON.stringify({data: value, time: curTime}));
		}

		function get(key, exp) {
			var data = localStorage.getItem(key);
			var dataObj = JSON.parse(data);
			if (!dataObj) {
				return dataObj;
			}
			if (new Date().getTime() - dataObj.time > exp) {
				return null
			} else {
				return dataObj.data;
			}
		}

		let URLKey = '{$urlKey}';
		let openUrl = get(URLKey, 30 * 86400 * 1000);
		if (!openUrl) {
			$.get('{:url("jump_mp")}', {
				channel_id: '{$channel_id}',
				platform  : '{$platform}',
				pid       : '{$pid}',
				path_type : '{$path_type}'
			}, (res) => {
				openUrl = res.wxmini_url;
				set(URLKey, openUrl)
				window.location.href = openUrl
			})
		} else {
			window.location.href = openUrl
		}
	</script>
</head>

<body>
<div class="full">
	<div id="public-web-container">
		<p>正在打开 “鑫互助小程序”...</p> <!-- replace -->
	</div>
</div>
</body>

</html>